<?php

/*

  Action	$8*

  +1 Card; +1 Action; +$1
  During your Buy phase, this costs $2 less per Action card you have in play, but not less than $0.

 */

class Peddler extends Card implements iAction, iKingdom, iProsperity {

    public function __construct() {
        parent::__construct("Peddler", 8);
        $this->undoPlay = false;
        $this->undoBuy = true;
    }

    public function getDescription() {
        return array(
            "+1 Card",
            "+1 Action",
            "+$1",
            "During your Buy phase, this costs $2 less per Action card you have in play, but not less than $0.");
    }

    public function play(Game $game, $isRealCard) {
        $game->addActions(1);
        $game->addMoney(new Price(1));
        $drawed_cards = $game->drawCards(1);
        ScreenDisplay::addScreenMessage($game, true, "get +1 action, +1$ and draw " . nicePrint($drawed_cards), "get +1 action, +1$ and draws " . sizeof($drawed_cards) . "cards");
		$game->cardActionFinished();
        return true;
    }

    public function getPrice($game) {
        if ($game == null)
            return $this->price;
        $phase = $game->getPhase();
        $substraction = 0;
        if ($phase == Phase_Buy || $phase == Phase_Payment) {
            $actionsInPlay = $game->getNumberOfActionsInPlay();

            $substraction = min(2 * $actionsInPlay, 8);
        }
        return new Price(8 - $substraction);
    }

}

?>